package com.fp.m7.client.widget;

import com.fp.m7.shared.Constants;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Image;

/**
 * A widget to represent a user (not his whole account).
 * 
 * @author 7
 */
public class UserSimpleWidget extends Composite {

    private Hyperlink hprlnkNickname;
    private Image image;

    public UserSimpleWidget() {
        AbsolutePanel panel = new AbsolutePanel();
        initWidget(panel);
        panel.setSize("379px", "70px");
        
        hprlnkNickname = new Hyperlink("", false, "");
        hprlnkNickname.setSize("300px", "50px");
        panel.add(hprlnkNickname, 66, 10);
        
        image = new Image(Constants.DEFAULT_AVATAR_URL);
        panel.add(image, 10, 10);
        image.setSize("50px", "50px");
    }

    public void setContents(String nickname, String profileToken, String imgUrl) {
        hprlnkNickname.setText(nickname);
        hprlnkNickname.setTargetHistoryToken(profileToken);
        image.setUrl(imgUrl == null ? Constants.DEFAULT_AVATAR_URL : imgUrl);
    }
}
